package mapStream;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class FilterDemo01 {
    public static void main(String[] args) {

        List<User>  userList= new ArrayList<>();
        userList.add(new User("aoyuan",1,"baotou"));
        userList.add(new User("aoyuan01",2,"bao"));
        userList.add(new User("aoyuan02",3,"tou"));
        //拿到用户集合中的数据并将用户名转化为大写
        List<String> collect = userList.stream().map(x -> x.getUsername().toUpperCase()).collect(Collectors.toList());
        collect.forEach(System.out::println);
       //拿到user集合选择数据存储在新的userDao集合中
        List<UserDao> collect1 = userList.stream().map(x -> {
            UserDao userDao = new UserDao();
            userDao.setUsername(x.getUsername());
            userDao.setAddress(x.getAddress());
            return userDao;
        }).collect(Collectors.toList());
        collect1.forEach(System.out::println);
    }
}
